<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="newsDB.*,newsEntity.*,java.sql.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/read.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
	$(function(){
		var $commentInput=$("#addComment :input");
		$("#addCommentCommit").click(function() {
			$.post("AddCommentServlet", $commentInput.serialize(), function(data) {
				if("success"==data){ 
					if($("#noComments").length>0){
						$("#noComments").remove();
						$("#commentsTable").append("<td colspan=\"6\">"+$("#ccontent").val()+"</td><tr><td colspan=\"6\">"+$("#cip").val()+"<hr /></td></tr> ");
					}else{
						$("#commentsTable tr:first").prepend("<tr><td colspan=\"6\">"+$("#ccontent").val()+"</td><tr><td colspan=\"6\">"+$("#cip").val()+"<hr /></td></tr> ");
					}
				}
				
			},"text");
		});
	});
</script>
</head>

<body>
<div id="container">
<div class="sidebar">
    <jsp:include page="/LeftServlet"></jsp:include>
</div>
  <div class="main">
    <div class="class_type"> <img src="images/class_type.gif" alt="新闻中心" /> </div>
    <div class="content">
      <ul class="classlist">
        <table width="80%" align="center">
          <tr width="100%">
            <td colspan="2" align="center">${news.ntitle}</td>
          </tr>
          <tr>
            <td colspan="2"><hr />
            </td>
          </tr>
          <tr>
            <td align="center">作者：${news.nauthor}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
             </a></td>
            <td align="left">发布时间：${news.ncreateDate}</td>
          </tr>          
          <tr>
            <td colspan="2" align="center"></td>
          </tr>
          <tr>
            <td colspan="2">    
			${news.ncontent}
			</td>
          </tr>
          <tr>
            <td colspan="2"><hr />
            </td>
          </tr>
        </table>
      </ul>
      <ul class="classlist">
        <table width="80%" align="center" id="commentsTable">
       <c:choose>
       	<c:when test="${empty commentsList}">
       	<tr>
       	  <td colspan="6" id="noComments"> 暂无评论！ </td>
       	  </tr>
	          <tr>
	            <td colspan="6"><hr />
	          </td>
	          </tr> 
       	</c:when>
       	<c:otherwise>
       	<c:forEach var="comment" items="${commentsList}">
       	<td colspan="6">${comment.ccontent}</td>
	         <tr>
	         <td colspan="6">${comment.cip}<hr /></td>
	         </tr>  
       	</c:forEach>
       	</c:otherwise>
       </c:choose>	
        </table>
      </ul>
      <ul class="classlist">
        <form action="" id="addComment">
        	<input type="hidden" value="${news.nid}" name="nid"/>
          <table width="80%" align="center">
          <tr>
          	<td>用户名</td>
          	<td>IP</td>
          </tr>
          <tr>
          	<td><input id="cauthor" name="cauthor" value="这家伙很懒什么也没留下"/></td>
          	<td><input name="cip" id="cip" value="${IP}" readonly="readonly" style="border:0px;"/></td>
          </tr>
          <tr>
          	<td colspan="2"><textarea name="ccontent" id="ccontent" cols="70" rows="10"></textarea></td>
          </tr>
          </table>
          <p style="text-align: center;" id="addCommentCommit">
          	<input type="button" value="提交"/>
          </p>
        </form>
      </ul>
    </div>
  </div>
</div>

<div id="friend">
  <h1 class="friend_t"> <img src="images/friend_ico.gif" alt="合作伙伴" /> </h1>
  <div class="friend_list">
    <ul>
      <li> <a href="#">百度</a> </li>
      <li> <a href="#">谷歌</a> </li>
      <li> <a href="#">新浪</a> </li>
      <li> <a href="#">网易</a> </li>
      <li> <a href="#">搜狐</a> </li>
      <li> <a href="#">人人</a> </li>
      <li> <a href="#">中国政府网</a> </li>
    </ul>
  </div>
</div>
<div id="footer">
  <p class=""> 24小时客户服务热线：010-68988888 &#160;&#160;&#160;&#160; <a href="#">常见问题解答</a> &#160;&#160;&#160;&#160; 新闻热线：010-627488888 <br />
    文明办网文明上网举报电话：010-627488888 &#160;&#160;&#160;&#160; 举报邮箱： <a href="#">jubao@jb-aptech.com.cn</a> </p>
  <p class="copyright"> Copyright &copy; 1999-2009 News China gov, All Right Reserver <br />
    新闻中国 版权所有 </p>
</div>
</body>
</html>

</html>